<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: FSelector::Base
  
    &mdash; FSelector Documentation
  
</title>

  <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />

  <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '..';
  if (relpath != '') relpath += '/';
</script>

  <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>


  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="../_index.html">Index (B)</a> &raquo; 
    <span class='title'><span class='object_link'><a href="../FSelector.html" title="FSelector (module)">FSelector</a></span></span>
     &raquo; 
    <span class="title">Base</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a id="class_list_link" href="#">Class List</a>
  
    <a id="method_list_link" href="#">Method List</a>
  
    <a id="file_list_link" href="#">File List</a>
  
</div>
      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: FSelector::Base
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">FSelector::Base</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
      <dt class="r2">Includes:</dt>
      <dd class="r2"><span class='object_link'><a href="../FileIO.html" title="FileIO (module)">FileIO</a></span>, <span class='object_link'><a href="../ReplaceMissingValues.html" title="ReplaceMissingValues (module)">ReplaceMissingValues</a></span></dd>
      
    
  
  
  
    <dt class="r1 last">Defined in:</dt>
    <dd class="r1 last">lib/fselector/algo_base/base.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>base class for a single feature selection algorithm</p>


  </div>
</div>
<div class="tags">
  

</div><div id="subclasses">
  <h2>Direct Known Subclasses</h2>
  <p class="children"><span class='object_link'><a href="BaseCFS.html" title="FSelector::BaseCFS (class)">BaseCFS</a></span>, <span class='object_link'><a href="BaseContinuous.html" title="FSelector::BaseContinuous (class)">BaseContinuous</a></span>, <span class='object_link'><a href="BaseDiscrete.html" title="FSelector::BaseDiscrete (class)">BaseDiscrete</a></span>, <span class='object_link'><a href="BaseEnsemble.html" title="FSelector::BaseEnsemble (class)">BaseEnsemble</a></span>, <span class='object_link'><a href="BaseRelief.html" title="FSelector::BaseRelief (class)">BaseRelief</a></span>, <span class='object_link'><a href="BaseReliefF.html" title="FSelector::BaseReliefF (class)">BaseReliefF</a></span>, <span class='object_link'><a href="LasVegasFilter.html" title="FSelector::LasVegasFilter (class)">LasVegasFilter</a></span>, <span class='object_link'><a href="LasVegasIncremental.html" title="FSelector::LasVegasIncremental (class)">LasVegasIncremental</a></span>, <span class='object_link'><a href="Random.html" title="FSelector::Random (class)">Random</a></span>, <span class='object_link'><a href="RandomSubset.html" title="FSelector::RandomSubset (class)">RandomSubset</a></span></p>
</div>




  <h2>Class Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#algo_type-class_method" title="algo_type (class method)">+ <strong>algo_type</strong> </a>
    

    
  </span>
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>class-level instance variable, type of feature selection algorithm.</p>
</div></span>
  
</li>

    
  </ul>




  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#algo_type-instance_method" title="#algo_type (instance method)">- <strong>algo_type</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>get the type of feature selection algorithm at class-level.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#each_class-instance_method" title="#each_class (instance method)">- <strong>each_class</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>iterator for each class, a block must be given.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#each_feature-instance_method" title="#each_feature (instance method)">- <strong>each_feature</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>iterator for each feature, a block must be given.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#each_sample-instance_method" title="#each_sample (instance method)">- <strong>each_sample</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>iterator for each sample with class label, 
a block must be given.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_class_labels-instance_method" title="#get_class_labels (instance method)">- (Array&lt;Symbol&gt;) <strong>get_class_labels</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>get class labels for all samples.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_classes-instance_method" title="#get_classes (instance method)">- (Array&lt;Symbol&gt;) <strong>get_classes</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>get (unique) classes labels.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_data-instance_method" title="#get_data (instance method)">- (Hash) <strong>get_data</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>get internal data.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_data_copy-instance_method" title="#get_data_copy (instance method)">- (Hash) <strong>get_data_copy</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>get a copy of internal data, by means of the standard Marshal library.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_feature_ranks-instance_method" title="#get_feature_ranks (instance method)">- (Hash) <strong>get_feature_ranks</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>get the ranked features based on their best scores.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_feature_scores-instance_method" title="#get_feature_scores (instance method)">- (Hash) <strong>get_feature_scores</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>get scores of all features for all classes.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_feature_type-instance_method" title="#get_feature_type (instance method)">- <strong>get_feature_type</strong>(feature = nil) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>get the feature type stored in @types.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_feature_values-instance_method" title="#get_feature_values (instance method)">- (Hash) <strong>get_feature_values</strong>(f, mv = nil, ck = nil) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>get feature values.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_features-instance_method" title="#get_features (instance method)">- (Array&lt;Symbol&gt;) <strong>get_features</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>get (unique) features.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_opt-instance_method" title="#get_opt (instance method)">- (Any) <strong>get_opt</strong>(key = nil) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>get non-data information for a given key.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_sample_size-instance_method" title="#get_sample_size (instance method)">- (Integer) <strong>get_sample_size</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>number of samples.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (Base) <strong>initialize</strong>(data = nil) </a>
    

    
  </span>
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>initialize from an existing data structure.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#select_feature%21-instance_method" title="#select_feature! (instance method)">- <strong>select_feature!</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>reconstruct data with selected features.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#select_feature_by_rank%21-instance_method" title="#select_feature_by_rank! (instance method)">- <strong>select_feature_by_rank!</strong>(criterion, my_ranks = nil) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>reconstruct data by feature rank satisfying criterion.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#select_feature_by_score%21-instance_method" title="#select_feature_by_score! (instance method)">- <strong>select_feature_by_score!</strong>(criterion, my_scores = nil) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>reconstruct data by feature score satisfying criterion.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#set_classes-instance_method" title="#set_classes (instance method)">- <strong>set_classes</strong>(classes) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>set classes.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#set_data-instance_method" title="#set_data (instance method)">- (nil) <strong>set_data</strong>(data) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>set data and clean relevant variables in case of data change.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#set_feature_type-instance_method" title="#set_feature_type (instance method)">- <strong>set_feature_type</strong>(feature, type) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>set feature name-type pair.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#set_features-instance_method" title="#set_features (instance method)">- <strong>set_features</strong>(features) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>set features.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#set_opt-instance_method" title="#set_opt (instance method)">- <strong>set_opt</strong>(key, value) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>set non-data information as a key-value pair.</p>
</div></span>
  
</li>

      
    </ul>
  


  
  
  
  
  
  
  
  <h3 class="inherited">Methods included from <span class='object_link'><a href="../ReplaceMissingValues.html" title="ReplaceMissingValues (module)">ReplaceMissingValues</a></span></h3>
  <p class="inherited"><span class='object_link'><a href="../ReplaceMissingValues.html#replace_by_fixed_value%21-instance_method" title="ReplaceMissingValues#replace_by_fixed_value! (method)">#replace_by_fixed_value!</a></span>, <span class='object_link'><a href="../ReplaceMissingValues.html#replace_by_knn_value%21-instance_method" title="ReplaceMissingValues#replace_by_knn_value! (method)">#replace_by_knn_value!</a></span>, <span class='object_link'><a href="../ReplaceMissingValues.html#replace_by_mean_value%21-instance_method" title="ReplaceMissingValues#replace_by_mean_value! (method)">#replace_by_mean_value!</a></span>, <span class='object_link'><a href="../ReplaceMissingValues.html#replace_by_median_value%21-instance_method" title="ReplaceMissingValues#replace_by_median_value! (method)">#replace_by_median_value!</a></span>, <span class='object_link'><a href="../ReplaceMissingValues.html#replace_by_most_seen_value%21-instance_method" title="ReplaceMissingValues#replace_by_most_seen_value! (method)">#replace_by_most_seen_value!</a></span></p>

  
  
  
  
  
  
  
  <h3 class="inherited">Methods included from <span class='object_link'><a href="../FileIO.html" title="FileIO (module)">FileIO</a></span></h3>
  <p class="inherited"><span class='object_link'><a href="../FileIO.html#data_from_csv-instance_method" title="FileIO#data_from_csv (method)">#data_from_csv</a></span>, <span class='object_link'><a href="../FileIO.html#data_from_libsvm-instance_method" title="FileIO#data_from_libsvm (method)">#data_from_libsvm</a></span>, <span class='object_link'><a href="../FileIO.html#data_from_random-instance_method" title="FileIO#data_from_random (method)">#data_from_random</a></span>, <span class='object_link'><a href="../FileIO.html#data_from_url-instance_method" title="FileIO#data_from_url (method)">#data_from_url</a></span>, <span class='object_link'><a href="../FileIO.html#data_from_weka-instance_method" title="FileIO#data_from_weka (method)">#data_from_weka</a></span>, <span class='object_link'><a href="../FileIO.html#data_to_csv-instance_method" title="FileIO#data_to_csv (method)">#data_to_csv</a></span>, <span class='object_link'><a href="../FileIO.html#data_to_libsvm-instance_method" title="FileIO#data_to_libsvm (method)">#data_to_libsvm</a></span>, <span class='object_link'><a href="../FileIO.html#data_to_weka-instance_method" title="FileIO#data_to_weka (method)">#data_to_weka</a></span></p>
<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <p class="signature first" id="initialize-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="FSelector::Base (class)">Base</a></span></tt>) <strong>initialize</strong>(data = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>initialize from an existing data structure</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


30
31
32</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 30</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
  <span class='ivar'>@data</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span> <span class='comment'># store data
</span><span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
  
</div>

  <div id="class_attr_details" class="attr_details">
    <h2>Class Attribute Details</h2>
    
      
      <span id="algo_type=-class_method"></span>
      <span id="algo_type-class_method"></span>
      <div class="method_details first">
  <p class="signature first" id="algo_type-class_method">
  
    + <strong>algo_type</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    
  <div class="note notetag">
    <strong>Note:</strong> 
    <div class='inline'><p>derived class (except for Base*** class) must set its own type with 
one of the following two:<br>
- :feature_weighting         # when algo outputs weight for each feature<br>
- :feature_subset_selection  # when algo outputs a subset of features</p>
</div>
  </div>

<p>class-level instance variable, type of feature selection algorithm.</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


20
21
22</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 20</span>

<span class='kw'>def</span> <span class='id identifier rubyid_algo_type'>algo_type</span>
  <span class='ivar'>@algo_type</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="algo_type-instance_method">
  
    - <strong>algo_type</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>get the type of feature selection algorithm at class-level</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


24
25
26</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 24</span>

<span class='kw'>def</span> <span class='id identifier rubyid_algo_type'>algo_type</span>
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_algo_type'>algo_type</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="each_class-instance_method">
  
    - <strong>each_class</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>iterator for each class, a block must be given. e.g. </p>

<pre class="code ruby"><code><span class='id identifier rubyid_each_class'>each_class</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span>
  <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_k'>k</span>
<span class='kw'>end</span>
</code></pre>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


42
43
44
45
46
47
48
49</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 42</span>

<span class='kw'>def</span> <span class='id identifier rubyid_each_class'>each_class</span>
  <span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
    <span class='id identifier rubyid_abort'>abort</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='kw'>__FILE__</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='kw'>__LINE__</span><span class='rbrace'>}</span><span class='tstring_content'>]: \n</span><span class='tstring_end'>&quot;</span></span><span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  block must be given!</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_get_classes'>get_classes</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span> <span class='kw'>yield</span> <span class='id identifier rubyid_k'>k</span> <span class='rbrace'>}</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="each_feature-instance_method">
  
    - <strong>each_feature</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>iterator for each feature, a block must be given. e.g.</p>

<pre class="code ruby"><code><span class='id identifier rubyid_each_feature'>each_feature</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span>
  <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_f'>f</span>
<span class='kw'>end</span>
</code></pre>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


59
60
61
62
63
64
65
66</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 59</span>

<span class='kw'>def</span> <span class='id identifier rubyid_each_feature'>each_feature</span>
  <span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
    <span class='id identifier rubyid_abort'>abort</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='kw'>__FILE__</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='kw'>__LINE__</span><span class='rbrace'>}</span><span class='tstring_content'>]: \n</span><span class='tstring_end'>&quot;</span></span><span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  block must be given!</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_get_features'>get_features</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span> <span class='kw'>yield</span> <span class='id identifier rubyid_f'>f</span> <span class='rbrace'>}</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="each_sample-instance_method">
  
    - <strong>each_sample</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>iterator for each sample with class label, 
a block must be given. e.g. </p>

<pre class="code ruby"><code><span class='id identifier rubyid_each_sample'>each_sample</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_s'>s</span><span class='op'>|</span>
  <span class='id identifier rubyid_print'>print</span> <span class='id identifier rubyid_k'>k</span>
  <span class='id identifier rubyid_s'>s</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_print'>print</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_v'>v</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span>
  <span class='id identifier rubyid_puts'>puts</span>
<span class='kw'>end</span>
</code></pre>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


79
80
81
82
83
84
85
86
87
88</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 79</span>

<span class='kw'>def</span> <span class='id identifier rubyid_each_sample'>each_sample</span>
  <span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
    <span class='id identifier rubyid_abort'>abort</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='kw'>__FILE__</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='kw'>__LINE__</span><span class='rbrace'>}</span><span class='tstring_content'>]: \n</span><span class='tstring_end'>&quot;</span></span><span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> block must be given!</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>else</span>      
    <span class='id identifier rubyid_get_data'>get_data</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_samples'>samples</span><span class='op'>|</span>
      <span class='id identifier rubyid_samples'>samples</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_s'>s</span><span class='op'>|</span> <span class='kw'>yield</span> <span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_s'>s</span> <span class='rbrace'>}</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_class_labels-instance_method">
  
    - (<tt><span class='object_link'><a href="../Array.html" title="Array (class)">Array</a></span>&lt;Symbol&gt;</tt>) <strong>get_class_labels</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>get class labels for all samples</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Array.html" title="Array (class)">Array</a></span>&lt;Symbol&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>class labels for all classes, 
same size as the number of samples</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


107
108
109
110
111
112
113
114
115
116
117</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 107</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_class_labels'>get_class_labels</span>
  <span class='kw'>if</span> <span class='kw'>not</span> <span class='ivar'>@cv</span>
    <span class='ivar'>@cv</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
    
    <span class='id identifier rubyid_each_sample'>each_sample</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_s'>s</span><span class='op'>|</span>
      <span class='ivar'>@cv</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_k'>k</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
  
  <span class='ivar'>@cv</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_classes-instance_method">
  
    - (<tt><span class='object_link'><a href="../Array.html" title="Array (class)">Array</a></span>&lt;Symbol&gt;</tt>) <strong>get_classes</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>get (unique) classes labels</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Array.html" title="Array (class)">Array</a></span>&lt;Symbol&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>unique class labels</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


96
97
98</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 96</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_classes'>get_classes</span>
  <span class='ivar'>@classes</span> <span class='op'>||=</span> <span class='ivar'>@data</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_data-instance_method">
  
    - (<tt>Hash</tt>) <strong>get_data</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>get internal data</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>internal data</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


228
229
230</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 228</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_data'>get_data</span>
  <span class='ivar'>@data</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_data_copy-instance_method">
  
    - (<tt>Hash</tt>) <strong>get_data_copy</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>get a copy of internal data, by means of the standard Marshal library</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>a copy of internal data</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


238
239
240</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 238</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_data_copy'>get_data_copy</span>
  <span class='const'>Marshal</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span><span class='const'>Marshal</span><span class='period'>.</span><span class='id identifier rubyid_dump'>dump</span><span class='lparen'>(</span><span class='ivar'>@data</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='ivar'>@data</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_feature_ranks-instance_method">
  
    - (<tt>Hash</tt>) <strong>get_feature_ranks</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>get the ranked features based on their best scores</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>feature ranks</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


328
329
330
331
332
333
334
335</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 328</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_feature_ranks'>get_feature_ranks</span>
  <span class='kw'>return</span> <span class='ivar'>@ranks</span> <span class='kw'>if</span> <span class='ivar'>@ranks</span> <span class='comment'># already done
</span>  
  <span class='comment'># make feature ranks from feature scores
</span>  <span class='id identifier rubyid_set_ranks_from_scores'>set_ranks_from_scores</span>
  
  <span class='ivar'>@ranks</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_feature_scores-instance_method">
  
    - (<tt>Hash</tt>) <strong>get_feature_scores</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>get scores of all features for all classes</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>{ feature =&gt; 
{ class_1 =&gt; score_1, class_2 =&gt; score_2, :BEST =&gt; score_best } }</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 305</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_feature_scores'>get_feature_scores</span>
  <span class='kw'>return</span> <span class='ivar'>@scores</span> <span class='kw'>if</span> <span class='ivar'>@scores</span> <span class='comment'># already done
</span>  
  <span class='id identifier rubyid_each_feature'>each_feature</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span>
    <span class='id identifier rubyid_calc_contribution'>calc_contribution</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='rparen'>)</span>
  <span class='kw'>end</span>
  
  <span class='comment'># best score for feature
</span>  <span class='ivar'>@scores</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='comma'>,</span> <span class='id identifier rubyid_ks'>ks</span><span class='op'>|</span>
    <span class='comment'># the larger, the better
</span>    <span class='ivar'>@scores</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:BEST</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_ks'>ks</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
  <span class='kw'>end</span>
  <span class='comment'>#@scores.each { |x,v| puts &quot;#{x} =&gt; #{v[:BEST]}&quot; }
</span>  
  <span class='ivar'>@scores</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_feature_type-instance_method">
  
    - <strong>get_feature_type</strong>(feature = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>get the feature type stored in @types</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>feature</span>
      
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>feature of interest<br>
return all feature name-type pairs if nil, 
otherwise reture the type for the feature of interest</p>
</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


202
203
204
205
206
207
208</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 202</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_feature_type'>get_feature_type</span><span class='lparen'>(</span><span class='id identifier rubyid_feature'>feature</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
  <span class='kw'>if</span> <span class='ivar'>@types</span>
    <span class='id identifier rubyid_feature'>feature</span> <span class='op'>?</span> <span class='ivar'>@types</span><span class='lbracket'>[</span><span class='id identifier rubyid_feature'>feature</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@types</span>
  <span class='kw'>else</span>
    <span class='kw'>nil</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_feature_values-instance_method">
  
    - (<tt>Hash</tt>) <strong>get_feature_values</strong>(f, mv = nil, ck = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>get feature values</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>f</span>
      
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>feature of interest</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>mv</span>
      
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>including missing feature values?
don&#39;t include missing feature values (recorded as nils)
if nil, include otherwise</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>ck</span>
      
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>class of interest.
return feature values for all classes, otherwise return feature
values for the specific class (ck)</p>
</div>
      
    </li>
  
</ul>

<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>feature values</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 156</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_feature_values'>get_feature_values</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='comma'>,</span> <span class='id identifier rubyid_mv'>mv</span><span class='op'>=</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_ck'>ck</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
  <span class='ivar'>@fvs</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
  
  <span class='kw'>if</span> <span class='kw'>not</span> <span class='ivar'>@fvs</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span> <span class='id identifier rubyid_f'>f</span>
    <span class='ivar'>@fvs</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
    
    <span class='id identifier rubyid_each_sample'>each_sample</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_s'>s</span><span class='op'>|</span>
      <span class='ivar'>@fvs</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='kw'>not</span> <span class='ivar'>@fvs</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span> <span class='id identifier rubyid_k'>k</span>
      <span class='kw'>if</span> <span class='id identifier rubyid_s'>s</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span> <span class='id identifier rubyid_f'>f</span>
        <span class='ivar'>@fvs</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_s'>s</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span>
      <span class='kw'>else</span>
        <span class='ivar'>@fvs</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='kw'>nil</span> <span class='comment'># for missing featue values
</span>      <span class='kw'>end</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
  
  <span class='kw'>if</span> <span class='id identifier rubyid_mv'>mv</span> <span class='comment'># include missing feature values
</span>    <span class='kw'>return</span> <span class='id identifier rubyid_ck'>ck</span> <span class='op'>?</span> <span class='ivar'>@fvs</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_ck'>ck</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@fvs</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span>
  <span class='kw'>else</span> <span class='comment'># don't include
</span>    <span class='kw'>return</span> <span class='id identifier rubyid_ck'>ck</span> <span class='op'>?</span> <span class='ivar'>@fvs</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_ck'>ck</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span> <span class='op'>:</span> <span class='ivar'>@fvs</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span>
  <span class='kw'>end</span>  
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_features-instance_method">
  
    - (<tt><span class='object_link'><a href="../Array.html" title="Array (class)">Array</a></span>&lt;Symbol&gt;</tt>) <strong>get_features</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>get (unique) features</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Array.html" title="Array (class)">Array</a></span>&lt;Symbol&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>unique features</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


139
140
141</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 139</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_features'>get_features</span>
  <span class='ivar'>@features</span> <span class='op'>||=</span> <span class='ivar'>@data</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_x'>x</span><span class='op'>|</span> <span class='id identifier rubyid_x'>x</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_y'>y</span><span class='op'>|</span> <span class='id identifier rubyid_y'>y</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_opt-instance_method">
  
    - (<tt>Any</tt>) <strong>get_opt</strong>(key = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    
  <div class="note notetag">
    <strong>Note:</strong> 
    <div class='inline'><p>return all non-data as a Hash if key == nil</p>
</div>
  </div>

<p>get non-data information for a given key</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>key</span>
      
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>key of non-data</p>
</div>
      
    </li>
  
</ul>

<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Any</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>value of non-data, can be any type</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


271
272
273
274
275
276
277</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 271</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_opt'>get_opt</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
  <span class='kw'>if</span> <span class='ivar'>@opts</span>
    <span class='id identifier rubyid_key'>key</span> <span class='op'>?</span> <span class='ivar'>@opts</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@opts</span>
  <span class='kw'>else</span>
    <span class='kw'>nil</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_sample_size-instance_method">
  
    - (<tt>Integer</tt>) <strong>get_sample_size</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>number of samples</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>sample size</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


294
295
296</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 294</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_sample_size'>get_sample_size</span>
  <span class='ivar'>@sz</span> <span class='op'>||=</span> <span class='id identifier rubyid_get_classes'>get_classes</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='int'>0</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_sz'>sz</span><span class='comma'>,</span> <span class='id identifier rubyid_k'>k</span><span class='op'>|</span> <span class='id identifier rubyid_sz'>sz</span><span class='op'>+</span><span class='id identifier rubyid_get_data'>get_data</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="select_feature!-instance_method">
  
    - <strong>select_feature!</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    
  <div class="note notetag">
    <strong>Note:</strong> 
    <div class='inline'><p>data structure will be altered. Derived class must 
implement its own get_feature_subset(). This is only available for 
the subset selection type of algorithms, see <a href="../index.html" title="README">README</a></p>
</div>
  </div>

<p>reconstruct data with selected features</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 345</span>

<span class='kw'>def</span> <span class='id identifier rubyid_select_feature!'>select_feature!</span>
  <span class='kw'>if</span> <span class='kw'>not</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_algo_type'>algo_type</span> <span class='op'>==</span> <span class='symbol'>:filter_by_feature_searching</span>
    <span class='id identifier rubyid_abort'>abort</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='kw'>__FILE__</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='kw'>__LINE__</span><span class='rbrace'>}</span><span class='tstring_content'>]: \n</span><span class='tstring_end'>&quot;</span></span><span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  select_feature! is the interface for the type of feature subset selection algorithms only. \n</span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  please consider select_featue_by_score! or select_feature_by_rank!, \n</span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  which is the interface for the type of feature weighting algorithms</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>
  
  <span class='comment'># derived class must implement its own one
</span>  <span class='id identifier rubyid_subset'>subset</span> <span class='op'>=</span> <span class='id identifier rubyid_get_feature_subset'>get_feature_subset</span>
  <span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_subset'>subset</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
  
  <span class='id identifier rubyid_my_data'>my_data</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
  
  <span class='id identifier rubyid_each_sample'>each_sample</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_s'>s</span><span class='op'>|</span>
    <span class='id identifier rubyid_my_data'>my_data</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
    <span class='id identifier rubyid_my_s'>my_s</span> <span class='op'>=</span> <span class='id identifier rubyid_s'>s</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_subset'>subset</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_f'>f</span> <span class='rbrace'>}</span>        
    <span class='id identifier rubyid_my_data'>my_data</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_my_s'>my_s</span> <span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_my_s'>my_s</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
  <span class='kw'>end</span>
  
  <span class='id identifier rubyid_set_data'>set_data</span><span class='lparen'>(</span><span class='id identifier rubyid_my_data'>my_data</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="select_feature_by_rank!-instance_method">
  
    - <strong>select_feature_by_rank!</strong>(criterion, my_ranks = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    
  <div class="note notetag">
    <strong>Note:</strong> 
    <div class='inline'><p>data structure will be altered. This is only available for 
the weighting type of algorithms, see <a href="../index.html" title="README">README</a></p>
</div>
  </div>

<p>reconstruct data by feature rank satisfying criterion</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>criterion</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>valid criterion can be &#39;&gt;11&#39;, &#39;&gt;=10&#39;, &#39;==1&#39;, &#39;&lt;=10&#39; or &#39;&lt;20&#39;</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>my_ranks</span>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>user customized feature ranks</p>
</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 413</span>

<span class='kw'>def</span> <span class='id identifier rubyid_select_feature_by_rank!'>select_feature_by_rank!</span><span class='lparen'>(</span><span class='id identifier rubyid_criterion'>criterion</span><span class='comma'>,</span> <span class='id identifier rubyid_my_ranks'>my_ranks</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
  <span class='kw'>if</span> <span class='kw'>not</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_algo_type'>algo_type</span> <span class='op'>==</span> <span class='symbol'>:filter_by_feature_weighting</span>
    <span class='id identifier rubyid_abort'>abort</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='kw'>__FILE__</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='kw'>__LINE__</span><span class='rbrace'>}</span><span class='tstring_content'>]: \n</span><span class='tstring_end'>&quot;</span></span><span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  select_feature_by_rank! is the interface for the type of feature weighting algorithms only. \n</span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  please consider select_featue!, \n</span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  which is the interface for the type of feature subset selection algorithms</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>
  
  <span class='comment'># user ranks or internal ranks
</span>  <span class='id identifier rubyid_ranks'>ranks</span> <span class='op'>=</span> <span class='id identifier rubyid_my_ranks'>my_ranks</span> <span class='op'>||</span> <span class='id identifier rubyid_get_feature_ranks'>get_feature_ranks</span>
  <span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_ranks'>ranks</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
  
  <span class='id identifier rubyid_my_data'>my_data</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
  
  <span class='id identifier rubyid_each_sample'>each_sample</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_s'>s</span><span class='op'>|</span>
    <span class='id identifier rubyid_my_data'>my_data</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
    <span class='id identifier rubyid_my_s'>my_s</span> <span class='op'>=</span> <span class='id identifier rubyid_s'>s</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_eval'>eval</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_ranks'>ranks</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_criterion'>criterion</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>        
    <span class='id identifier rubyid_my_data'>my_data</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_my_s'>my_s</span> <span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_my_s'>my_s</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
  <span class='kw'>end</span>
  
  <span class='id identifier rubyid_set_data'>set_data</span><span class='lparen'>(</span><span class='id identifier rubyid_my_data'>my_data</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="select_feature_by_score!-instance_method">
  
    - <strong>select_feature_by_score!</strong>(criterion, my_scores = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    
  <div class="note notetag">
    <strong>Note:</strong> 
    <div class='inline'><p>data structure will be altered. This is only available for 
the weighting type of algorithms, see <a href="../index.html" title="README">README</a></p>
</div>
  </div>

<p>reconstruct data by feature score satisfying criterion</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>criterion</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>valid criterion can be &#39;&gt;0.5&#39;, &#39;&gt;=0.4&#39;, &#39;==2.0&#39;, &#39;&lt;=1.0&#39; or &#39;&lt;0.2&#39;</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>my_scores</span>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>user customized feature scores</p>
</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 379</span>

<span class='kw'>def</span> <span class='id identifier rubyid_select_feature_by_score!'>select_feature_by_score!</span><span class='lparen'>(</span><span class='id identifier rubyid_criterion'>criterion</span><span class='comma'>,</span> <span class='id identifier rubyid_my_scores'>my_scores</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
  <span class='kw'>if</span> <span class='kw'>not</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_algo_type'>algo_type</span> <span class='op'>==</span> <span class='symbol'>:filter_by_feature_weighting</span>
    <span class='id identifier rubyid_abort'>abort</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='kw'>__FILE__</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='kw'>__LINE__</span><span class='rbrace'>}</span><span class='tstring_content'>]: \n</span><span class='tstring_end'>&quot;</span></span><span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  select_feature_by_score! is the interface for the type of feature weighting algorithms only. \n</span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  please consider select_featue!, \n</span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  which is the interface for the type of feature subset selection algorithms</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>
  
  <span class='comment'># user scores or internal scores
</span>  <span class='id identifier rubyid_scores'>scores</span> <span class='op'>=</span> <span class='id identifier rubyid_my_scores'>my_scores</span> <span class='op'>||</span> <span class='id identifier rubyid_get_feature_scores'>get_feature_scores</span>
  <span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_scores'>scores</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
  
  <span class='id identifier rubyid_my_data'>my_data</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
  
  <span class='id identifier rubyid_each_sample'>each_sample</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_s'>s</span><span class='op'>|</span>
    <span class='id identifier rubyid_my_data'>my_data</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
    <span class='id identifier rubyid_my_s'>my_s</span> <span class='op'>=</span> <span class='id identifier rubyid_s'>s</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_eval'>eval</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_scores'>scores</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:BEST</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_criterion'>criterion</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>       
    <span class='id identifier rubyid_my_data'>my_data</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_my_s'>my_s</span> <span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_my_s'>my_s</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
  <span class='kw'>end</span>
      
  <span class='id identifier rubyid_set_data'>set_data</span><span class='lparen'>(</span><span class='id identifier rubyid_my_data'>my_data</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="set_classes-instance_method">
  
    - <strong>set_classes</strong>(classes) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>set classes</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>classes</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Array.html" title="Array (class)">Array</a></span>&lt;Symbol&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>source unique class labels</p>
</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


125
126
127
128
129
130
131
132</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 125</span>

<span class='kw'>def</span> <span class='id identifier rubyid_set_classes'>set_classes</span><span class='lparen'>(</span><span class='id identifier rubyid_classes'>classes</span><span class='rparen'>)</span>
  <span class='kw'>if</span> <span class='id identifier rubyid_classes'>classes</span> <span class='kw'>and</span> <span class='id identifier rubyid_classes'>classes</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'>==</span> <span class='const'>Array</span>
    <span class='ivar'>@classes</span> <span class='op'>=</span> <span class='id identifier rubyid_classes'>classes</span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_abort'>abort</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='kw'>__FILE__</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='kw'>__LINE__</span><span class='rbrace'>}</span><span class='tstring_content'>]: \n</span><span class='tstring_end'>&quot;</span></span><span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  classes must be a Array object!</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="set_data-instance_method">
  
    - (<tt>nil</tt>) <strong>set_data</strong>(data) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>set data and clean relevant variables in case of data change</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>data</span>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>source data structure</p>
</div>
      
    </li>
  
</ul>

<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>nil</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>to suppress console echo of data in irb</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


249
250
251
252
253
254
255
256
257
258
259
260</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 249</span>

<span class='kw'>def</span> <span class='id identifier rubyid_set_data'>set_data</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
  <span class='kw'>if</span> <span class='id identifier rubyid_data'>data</span> <span class='kw'>and</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'>==</span> <span class='const'>Hash</span>
    <span class='comment'># clear variables
</span>    <span class='id identifier rubyid_clear_vars'>clear_vars</span> <span class='kw'>if</span> <span class='ivar'>@data</span>
    <span class='ivar'>@data</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span> <span class='comment'># set new data structure
</span>  <span class='kw'>else</span>
    <span class='id identifier rubyid_abort'>abort</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='kw'>__FILE__</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='kw'>__LINE__</span><span class='rbrace'>}</span><span class='tstring_content'>]: \n</span><span class='tstring_end'>&quot;</span></span><span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  data must be a Hash object!</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>
  
  <span class='kw'>nil</span> <span class='comment'># suppress console echo of data in irb
</span><span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="set_feature_type-instance_method">
  
    - <strong>set_feature_type</strong>(feature, type) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>set feature name-type pair</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>feature</span>
      
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>feature name</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>type</span>
      
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>feature type</p>
</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


217
218
219
220</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 217</span>

<span class='kw'>def</span> <span class='id identifier rubyid_set_feature_type'>set_feature_type</span><span class='lparen'>(</span><span class='id identifier rubyid_feature'>feature</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
  <span class='ivar'>@types</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
  <span class='ivar'>@types</span><span class='lbracket'>[</span><span class='id identifier rubyid_feature'>feature</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_type'>type</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="set_features-instance_method">
  
    - <strong>set_features</strong>(features) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>set features</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>features</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Array.html" title="Array (class)">Array</a></span>&lt;Symbol&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>source unique features</p>
</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


185
186
187
188
189
190
191
192</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 185</span>

<span class='kw'>def</span> <span class='id identifier rubyid_set_features'>set_features</span><span class='lparen'>(</span><span class='id identifier rubyid_features'>features</span><span class='rparen'>)</span>
  <span class='kw'>if</span> <span class='id identifier rubyid_features'>features</span> <span class='kw'>and</span> <span class='id identifier rubyid_features'>features</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'>==</span> <span class='const'>Array</span>
    <span class='ivar'>@features</span> <span class='op'>=</span> <span class='id identifier rubyid_features'>features</span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_abort'>abort</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='kw'>__FILE__</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='kw'>__LINE__</span><span class='rbrace'>}</span><span class='tstring_content'>]: \n</span><span class='tstring_end'>&quot;</span></span><span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  features must be a Array object!</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="set_opt-instance_method">
  
    - <strong>set_opt</strong>(key, value) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>set non-data information as a key-value pair</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>key</span>
      
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>key of non-data</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>value</span>
      
      
        <span class='type'>(<tt>Any</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>value of non-data, can be any type</p>
</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


283
284
285
286</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/algo_base/base.rb', line 283</span>

<span class='kw'>def</span> <span class='id identifier rubyid_set_opt'>set_opt</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
  <span class='ivar'>@opts</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='comment'># store non-data information
</span>  <span class='ivar'>@opts</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Mon Nov  5 11:19:45 2012 by 
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.7.5 (ruby-1.9.3).
</div>

  </body>
</html>